//
//  QYGDrollRecordCell.m
//  wawaji_ios
//
//  Created by 云+物娱 on 2017/12/8.
//  Copyright © 2017年 yiguo qi. All rights reserved.
//

#import "QYGDrollRecordCell.h"

@interface QYGDrollRecordCell()

@property (nonatomic, strong) UIImageView *headerView;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *arrowLabel;

@end

@implementation QYGDrollRecordCell

- (void)drollRecordCellWithIconStr:(NSString *)iconStr nameStr:(NSString *)nameStr detailStr:(NSString *)detailStr{
    _iconStr = iconStr;
    _nameStr = nameStr;
    _detailStr = detailStr;
    
    [self.headerView setImageURL:[NSURL URLWithString:iconStr]];
    self.nameLabel.text = nameStr;
    self.arrowLabel.text = detailStr;
    
    [self.nameLabel sizeToFit];
    [self.arrowLabel sizeToFit];
}
- (void)setDetailStr:(NSString *)detailStr{
    _detailStr = detailStr;
    self.arrowLabel.text = detailStr;
    [self.arrowLabel sizeToFit];

}
- (void)setNameStr:(NSString *)nameStr{
    _nameStr = nameStr;
    self.nameLabel.text = nameStr;
    [self.nameLabel sizeToFit];
}
- (void)setIconStr:(NSString *)iconStr{
    _iconStr = iconStr;
    [self.headerView setImageURL:[NSURL URLWithString:iconStr]];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupUI];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.headerView.x = ScaleW(15);
    self.headerView.y = (self.height - self.headerView.height) * 0.5;
    
    self.nameLabel.centerY = self.headerView.centerY;
    self.nameLabel.x = CGRectGetMaxX(self.headerView.frame) + ScaleW(14);
    
    self.arrowLabel.centerY = self.nameLabel.centerY;
    self.arrowLabel.x = self.width - self.arrowLabel.width - ScaleW(15);
}
 #pragma mark - setUI

- (void)setupUI{
    [self addSubview:self.headerView];
    [self addSubview:self.nameLabel];
    [self addSubview:self.arrowLabel];
}

#pragma mark lazy

- (UILabel *)arrowLabel{
    
    if(!_arrowLabel){
        _arrowLabel = [UILabel labelWithText:@"22小时88分99秒前" setFont:ScaleFont(13) setTextColor:[UIColor colorWithHex:@"93979B"] setTextAlignment:NSTextAlignmentRight];
        _arrowLabel.size = CGSizeMake(ScaleW(200), ScaleW(20));
        _arrowLabel.numberOfLines = 1;
    }
    return _arrowLabel;
}

- (UILabel *)nameLabel{
    if(!_nameLabel){
        _nameLabel = [UILabel labelWithText:@"抓取用户 " setFont:ScaleFont(13) setTextColor:[UIColor colorWithHex:@"494B4D"] setTextAlignment:NSTextAlignmentLeft];
//        [_nameLabel sizeToFit];
        _nameLabel.numberOfLines = 1;
        
    }
    return _nameLabel;
}
- (UIImageView *)headerView{
    if(!_headerView){
        _headerView = [[UIImageView alloc] init];
        _headerView.size = CGSizeMake(ScaleW(40), ScaleW(40));
        _headerView.layer.cornerRadius = ScaleW(20);
        _headerView.backgroundColor = [UIColor cm_mainColor];
        
    }
    return _headerView;
}
@end
